﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/*
 * http://www.spoj.pl/problems/MUL/
 */ 

namespace CSharpAlgorithm
{
    class FastMultiplication
    {
        public FastMultiplication()
        {
            int testCase = Int32.Parse(TestConsole.ReadLine());
            while (testCase-- > 0)
            {
                string[] input = TestConsole.ReadLine().Split(' ');
                string a = input[0].Trim();
                List<long> aList = new List<long>();
                while (a.Length > 0)
                {
                    string sub;
                    if (a.Length > 9)
                    {
                        sub = a.Substring(a.Length - 9);
                    }
                    else
                    {
                        sub = a;
                    }
                    aList.Add(long.Parse(sub));
                    a = a.Substring(0, a.Length - sub.Length);
                }
                string b = input[1].Trim();
                List<long> bList = new List<long>();
                while (b.Length > 0)
                {
                    string sub;
                    if (b.Length > 9)
                    {
                        sub = b.Substring(b.Length - 9);
                    }
                    else
                    {
                        sub = b;
                    }
                    bList.Add(long.Parse(sub));
                    b = b.Substring(0, b.Length - sub.Length);
                }
                long[] result = new long[aList.Count + bList.Count];
                for (int indexA = 0; indexA < aList.Count; indexA++)
                {
                    for (int indexB = 0; indexB < bList.Count; indexB++)
                    {
                        result[indexA + indexB] += aList[indexA] * bList[indexB];
                    }
                }
                StringBuilder gop = new StringBuilder();
                for (int i = 0; i < result.Length - 1; i++)
                {
                    result[i + 1] += result[i] / 1000000000;
                    result[i] = result[i] % 1000000000;
                }
                for (int i = result.Length - 1; i >= 0; i--)
                {
                    if (gop.Length > 0 || result[i] > 0)
                    {
                        gop.Append(result[i]);
                    }
                }
                if (gop.Length > 0)
                {
                    Console.WriteLine(gop.ToString());
                }
                else
                {
                    Console.WriteLine("0");
                }
            }
        }
    }
}